import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
const routes = [
  {
    path: '/',
    redirect:"/home"
  },
  {//首页
    path: '/home',
    name: 'home',
    component: HomeView,
    meta:{
      footshow:true,
    },
  },
  {//商城
    path: '/shop',
    name: 'shop',
    component: () => import('../views/shopView.vue'),
    meta:{
      footshow:true,
      keep:true
    },
    // beforeRouteLeave(to,from, next) {
    //   // 设置下一个路由的 meta
    //   to.meta.keep = false;
    //   next();
    // }

  },
  {//收藏夹
    path: '/collection',
    name: 'collection',
    component: () => import('../views/collectionView.vue'),
    meta:{
      footshow:true,
    },
  },
  {//个人中心
    path: '/user',
    name: 'user',
    component: () => import('../views/UserView.vue'),
    meta:{
      footshow:true,
    },
  },
  {//菜谱详情页
    path: '/about',
    name: 'about',
    component: () => import('../views/AboutView.vue')
  },
  {//商城详情页
    path: '/shopDetail',
    name: 'shopDetail',
    component: () => import('../views/shopDetail.vue')
  },
  {//商城搜索页
    path: '/shopSearch',
    name: 'shopSearch',
    component: () => import('../views/shopSearch.vue')
  },
  {//搜索页
    path: '/search',
    name: 'search',
    component: () => import('../views/SearchView.vue'),
  },
  {//搜索列表页
    path: '/searList',
    name: 'searList',
    component: () => import('../views/SearListView.vue'),
  },
  {//商城搜索列表页
    path: '/shopSearchList',
    name: 'shopSearchList',
    meta:{
      keep:true
    },
    beforeRouteLeave(to,from, next) {
      // 设置下一个路由的 meta
      to.meta.keep = false;
      next();
    },
    component: () => import('../views/shopSearchList.vue'),
  },
  {//商城搜索列表页
    path: '/moreComment',
    name: 'moreComment',
    component: () => import('../views/moreComment.vue'),
  },
  {//商城购物车
    path: '/ShoppingCart',
    name: 'ShoppingCart',
    component: () => import('../views/ShoppingCart.vue'),
  },
  {//购物确认订单
    path: '/ConfirmOrder',
    name: 'ConfirmOrder',
    component: () => import('../views/ConfirmOrder.vue'),
  },
  {//购物收货地址
    path: '/ShipAddress',
    name: 'ShipAddress',
    component: () => import('../views/ShipAddress.vue'),
  },
  {//购物新增地址
    path: '/AddAddress',
    name: 'AddAddress',
    component: () => import('../views/AddAddress.vue'),
  },
  {//分类页
    path:'/branch',
    name:'branch',
    component: () => import('../views/BranchView.vue'),
  },
  {//关注页
    path:'/follow',
    name:'follow',
    component: () => import('../views/FollowView.vue'),
  },
  {//用户页
    path:'/person',
    name:'person',
    component: () => import('../views/PersonView.vue'),
  },
  {//评价页
    path:'/comment',
    name:'comment',
    component: () => import('../views/commentView.vue'),
  },
  {//订单
    path:'/shopOrder',
    name:'shopOrder',
    component: () => import('../views/shopOrder.vue'),
  },
  {//菜谱编辑页
    path:'/edit',
    name:'edit',
    component: () => import('../views/EditView.vue'),

  },
  {//登录页
    path:'/login',
    name:'login',
    component: () => import('../views/loginView.vue'),

  }

  
]




const router = createRouter({
  history: createWebHistory(),
  routes,
    scrollBehavior() {
      return { left: 0, top: 0 }
    }
})


export default router
